/**
 * 路径转驼峰变量
 * @param {String} path 路径
 */
export default function path2var(path) {
    const reg = /(\.|\:)?\/([a-z-_]+)\.js$/;
    const matches = path.match(reg);
    if (matches) {
        const underlineVar = matches[2].replace(/\//g, '-').replace(/_/g, '-');
        return underline2camelCase(underlineVar);
    }
    return path;
}

/**
 * 中划线转驼峰
 * @param {String} underline 中划线字符串
 */
function underline2camelCase(underline) {
    return underline.replace(/-(\w)/g, ($, $1) => {
        console.log($1);
        return $1.toUpperCase();
    });
}
